import { uploadType, regularRule } from '@/utils/util'

export const detailConfig: any = {
	label: '运营记录详情',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	labelWidth: '200px',
	column: [
		//-------------------- 运营记录 ----------------
		{
			label: '运营单位名称',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 12,
		},
		{
			label: '运营单位统一社会信用代码',
			prop: 'creditCode',
			type: 'input',
			rules: [{ pattern: regularRule.code, message: '请输入正确的运营单位统一社会信用代码' }],
			span: 12,
		},
		{
			label: '合同签订开始日期',
			prop: 'startDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 12,
		},
		{
			label: '合同签订结束日期',
			prop: 'finishDate',
			type: 'date',
			format: 'YYYY年MM月DD日',
			valueFormat: 'YYYY-MM-DD',
			span: 12,
		},
		{
			label: '运营单位联系人姓名',
			prop: 'name',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 12,
		},
		{
			label: '合同运营内容',
			prop: 'operateContent',
			type: 'textarea',
			maxlength: '500',
			showWordLimit: true,
			span: 24,
		},
		{
			label: '合同',
			prop: 'contract',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			showFileList: true,
			limit: 9,
			multiple: true,
			span: 12,
		},
	],
}
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{ label: '运营单位', prop: 'organizationName' },
		{ label: '合同起始日期', prop: 'startToEnd' },
		{ label: '联系人', prop: 'name' },
		{ label: '运营内容', prop: 'operateContent' },
		{
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
export const formConfig = {
	label: '数据管理设置',
	prop: 'base0',
	inline: false,
	showBtn: true,
	labelPosition: 'left',
	column: detailConfig.column,
}
export const baseConfig: any = {
	pageName: '养老设施-运营记录',
	addLabel: '添加',
	dictcodes: [],
	rowKey: 'id',
	tipLabel: 'batch',
	api: {
		index: 'view_dpOperateRecord_page',
		add: 'view_dpOperateRecord_add',
		edit: 'view_dpOperateRecord_edit',
		delete: 'view_dpOperateRecord_del',
	},
	auth: {
		index: 'view_dpOperateRecord_page',
		add: 'view_dpOperateRecord_add',
		edit: 'view_dpOperateRecord_edit',
		delete: 'view_dpOperateRecord_del',
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'detail',
			auth: '',
			text: true,
			show: true,
		},
		{
			icon: 'editor',
			label: '编辑',
			type: 'primary',
			operate: 'edit',
			auth: 'view_dataManagementSettings_edit',
			text: true,
			show: true,
		},

		{
			icon: 'delete',
			label: '删除',
			type: 'primary',
			operate: 'delete',
			auth: 'view_dataManagementSettings_del',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	tableConfig,
	formConfig,
	detailConfig,
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			let startToEnd = item.startDate + '-' + item.finishDate
			return {
				...item,
				startToEnd,
			}
		})
		console.log(tableData, 'tableData')
		return Promise.resolve(Object.freeze(tableData))
	},
}
